<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
</head>
<body>
<nav th:fragment="navbar" class="navbar navbar-expand-lg navbar-dark" 
     th:classappend="${userRole == 'admin' or userRole == 'super_admin'} ? 'bg-primary' : 
                     (${userRole == 'customer_service'} ? 'bg-info' : 'bg-success')">
    <div class="container-fluid">
        <!-- 根据角色显示不同的品牌链接和图标 -->
        <a class="navbar-brand" 
           th:href="${userRole == 'admin' or userRole == 'super_admin'} ? '/admin/dashboard' : 
                    (${userRole == 'customer_service'} ? '/customer-service/dashboard' : '/customer/dashboard')">
            <i th:class="${userRole == 'admin' or userRole == 'super_admin'} ? 'bi bi-gear-fill' : 
                         (${userRole == 'customer_service'} ? 'bi bi-headset' : 'bi bi-shop')"></i>
            <span th:text="${userRole == 'admin' or userRole == 'super_admin'} ? '管理中心' : 
                           (${userRole == 'customer_service'} ? '客服工作台' : '用户中心')"></span>
        </a>
        
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <!-- 管理员导航项 -->
                <li class="nav-item" th:if="${userRole == 'admin' or userRole == 'super_admin'}">
                    <a class="nav-link" href="/admin/users">
                        <i class="bi bi-people"></i> 用户管理
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'admin' or userRole == 'super_admin'}">
                    <a class="nav-link" href="/admin/products">
                        <i class="bi bi-box"></i> 商品管理
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'admin' or userRole == 'super_admin'}">
                    <a class="nav-link" href="/admin/categories">
                        <i class="bi bi-tags"></i> 分类管理
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'admin' or userRole == 'super_admin'}">
                    <a class="nav-link" href="/admin/orders">
                        <i class="bi bi-receipt"></i> 订单管理
                    </a>
                </li>

                <!-- 客服导航项 -->
                <li class="nav-item" th:if="${userRole == 'customer_service'}">
                    <a class="nav-link" href="/customer-service/tickets">
                        <i class="bi bi-chat-dots"></i> 客户咨询
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'customer_service'}">
                    <a class="nav-link" href="/customer-service/orders">
                        <i class="bi bi-receipt"></i> 订单处理
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'customer_service'}">
                    <a class="nav-link" href="/customer-service/customers">
                        <i class="bi bi-people"></i> 客户信息
                    </a>
                </li>

                <!-- 普通用户导航项 -->
                <li class="nav-item" th:if="${userRole == 'customer'}">
                    <a class="nav-link" href="/customer/products">
                        <i class="bi bi-shop"></i> 商品浏览
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'customer'}">
                    <a class="nav-link" href="/customer/cart">
                        <i class="bi bi-cart"></i> 购物车
                    </a>
                </li>
                <li class="nav-item" th:if="${userRole == 'customer'}">
                    <a class="nav-link" href="/customer/orders">
                        <i class="bi bi-receipt"></i> 我的订单
                    </a>
                </li>
            </ul>
            
            <ul class="navbar-nav">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                        <i class="bi bi-person-circle"></i> 
                        <span th:text="${username != null ? username : 
                                       (userRole == 'admin' ? '管理员' : 
                                       (userRole == 'super_admin' ? '超级管理员' : 
                                       (userRole == 'customer_service' ? '客服' : '用户')))}"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" 
                               th:href="${userRole == 'admin' or userRole == 'super_admin'} ? '/admin/profile' : 
                                        (${userRole == 'customer_service'} ? '/customer-service/profile' : '/customer/profile')">
                               <i class="bi bi-person"></i> 个人信息</a></li>
                        <li><a class="dropdown-item"
                               th:href="${userRole == 'admin' or userRole == 'super_admin'} ? '/admin/settings' : 
                                        (${userRole == 'customer_service'} ? '/customer-service/settings' : '/customer/settings')">
                               <i class="bi bi-gear"></i> 设置</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="/logout">
                               <i class="bi bi-box-arrow-right"></i> 退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
</body>
</html>
